import { Controller, Inject, Post, Files, Fields } from '@midwayjs/decorator';
import { BaseController } from '@core/index';
import { FileService } from '@service/file.service';

@Controller('/api')
export class FileController extends BaseController {
  @Inject()
  fileService: FileService;

  // @Post('/uploadBase64')
  // async uploadBase64(@Files() files, @Fields() fields) {
  //   return {
  //     files,
  //     fields,
  //   };
  // }
  @Post('/uploadForm')
  async uploadForm(@Files() files, @Fields() fields) {
    const result = await this.fileService.uploadForm(files, fields);
    if (!result) {
      return this.success(400, '上传失败', result);
    }
    return this.success(200, '上传成功 ', result);
  }
}
